package be.ipl.finito.domaine;

import java.io.Serializable;
import java.util.SortedSet;
import java.util.TreeSet;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

import be.ipl.finito.util.Consts;

@SuppressWarnings("serial")
@Entity
@Table(name = "JETONS", schema = "FINITO")
public class Jeton implements Serializable {
	public static final int NB_JETONS = Consts.NB_JETONS;

	@Id
	@Min(1)
	@Max(NB_JETONS)
	private int numero;

	//private static SortedSet<Jeton> jetons = new TreeSet<Jeton>();
	/*
	 * static { for(int i=1;i<13;i++){ jetons.add(new Jeton(i)); } }
	 */
	@NotNull
	private String urlImage;
	
	public Jeton(){
		
	}

	public Jeton(int num, String url) {
		this.numero = num;
		this.urlImage = url;	
	}

	public Jeton(int num) {
		this.numero = num;
		this.urlImage = "";
	}
	/*
	public static SortedSet<Jeton> getJetons() {
		return jetons;
	}
	*/
	public int getNumero() {
		return numero;
	}

	public String getUrlImage() {
		return urlImage;
	}

	@Override
	public int hashCode() {
		return numero;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		Jeton other = (Jeton) obj;
		if (numero != other.numero) {
			return false;
		}
		return true;
	}

}
